package com.px.plan.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.px.framework.aes.AesSecurityParameter;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.px.common.annotation.Log;
import com.px.common.core.controller.BaseController;
import com.px.common.core.domain.AjaxResult;
import com.px.common.enums.BusinessType;
import com.px.plan.domain.PlanMarkCoordinate;
import com.px.plan.service.IPlanMarkCoordinateService;
import com.px.common.utils.poi.ExcelUtil;
import com.px.common.core.page.TableDataInfo;

/**
 * 区域协作点记录Controller
 * 
 * @author WRJ
 * @date 2024-08
 */
@Api("飞行预案区域标记点管理")
@RestController
@RequestMapping("/plan/coordinate")
public class PlanMarkCoordinateController extends BaseController
{
    @Autowired
    private IPlanMarkCoordinateService planMarkCoordinateService;

    /**
     * 查询区域协作点记录列表
     */
    @ApiOperation("飞行预案区域标记点列表")
    @PreAuthorize("@ss.hasPermi('plan:coordinate:list')")
    @GetMapping("/list")
    @AesSecurityParameter(outEncode = true)
    public TableDataInfo list(PlanMarkCoordinate planMarkCoordinate)
    {
        startPage();
        List<PlanMarkCoordinate> list = planMarkCoordinateService.selectPlanMarkCoordinateList(planMarkCoordinate);
        return getDataTable(list);
    }

    /**
     * 导出区域协作点记录列表
     */
    @ApiOperation("导出飞行预案区域标记点")
    @PreAuthorize("@ss.hasPermi('plan:coordinate:export')")
    @Log(title = "区域协作点记录", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @AesSecurityParameter
    public void export(HttpServletResponse response, PlanMarkCoordinate planMarkCoordinate)
    {
        List<PlanMarkCoordinate> list = planMarkCoordinateService.selectPlanMarkCoordinateList(planMarkCoordinate);
        ExcelUtil<PlanMarkCoordinate> util = new ExcelUtil<PlanMarkCoordinate>(PlanMarkCoordinate.class);
        util.exportExcel(response, list, "区域协作点记录数据");
    }

    /**
     * 获取区域协作点记录详细信息
     */
    @ApiOperation("预案区域标记点列表详情")
    @PreAuthorize("@ss.hasPermi('plan:coordinate:query')")
    @GetMapping(value = "/{id}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(planMarkCoordinateService.selectPlanMarkCoordinateById(id));
    }

    /**
     * 新增区域协作点记录
     */
    @ApiOperation("新增预案区域标记点列表")
    @PreAuthorize("@ss.hasPermi('plan:coordinate:add')")
    @Log(title = "区域协作点记录", businessType = BusinessType.INSERT)
    @PostMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult add(@RequestBody PlanMarkCoordinate planMarkCoordinate)
    {
        return toAjax(planMarkCoordinateService.insertPlanMarkCoordinate(planMarkCoordinate));
    }

    /**
     * 修改区域协作点记录
     */
    @ApiOperation("修改预案区域标记点列表")
    @PreAuthorize("@ss.hasPermi('plan:coordinate:edit')")
    @Log(title = "区域协作点记录", businessType = BusinessType.UPDATE)
    @PutMapping
    @AesSecurityParameter(outEncode = true)
    public AjaxResult edit(@RequestBody PlanMarkCoordinate planMarkCoordinate)
    {
        return toAjax(planMarkCoordinateService.updatePlanMarkCoordinate(planMarkCoordinate));
    }

    /**
     * 删除区域协作点记录
     */
    @ApiOperation("删除预案区域标记点列表")
    @PreAuthorize("@ss.hasPermi('plan:coordinate:remove')")
    @Log(title = "区域协作点记录", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    @AesSecurityParameter(outEncode = true)
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(planMarkCoordinateService.deletePlanMarkCoordinateByIds(ids));
    }
}
